/**
 *
 * @type {Array<{name: string, value: number}>}
 */
/* const managerAgeData = [
  { value: 2, name: '局级' },
  { value: 3, name: '处级' },
  { value: 6, name: '科级' },
  { value: 8, name: '其他' }
] */

/**
 * 一把手年龄情况
 * @param data
 * @returns {unknown[]}
 */
export const getTalkPie = data => ({
  title: {
    text: `{value|${data.reduce((acc, cur) => {
      return acc + cur.value
    }, 0)}}\n{title|谈话对象/\n人次}`,
    top: 'middle',
    textAlign: 'center',
    left: '39%',
    textStyle: {
      rich: {
        value: {
          fontSize: 18,
          lineHeight: 24,
          color: '#4AA4F8'
        },
        title: {
          fontSize: 14,
          color: '#000'
        }
      }
    }
  },
  tooltip: {
    trigger: 'item',
    appendToBody: true,
    formatter: '{b} : {c}人({d}%)'
  },
  legend: {
    orient: 'vertical',
    right: 0,
    top: 0
  },
  series: [
    {
      name: '',
      type: 'pie',
      radius: ['50%', '80%'],
      center: ['40%', '50%'],
      avoidLabelOverlap: false,
      label: {
        show: true,
        align: 'center',
        formatter: '{c}',
        color: '#fff',
        position: 'inside'
      },
      labelLine: {
        show: false
      },
      data: data.map(value => ({ ...value, name: value.label }))
    }
  ],
  color: ['#5A9CD4', '#6CC7FF', '#FBC958', '#EF6666']
})
